package xjy.smartcommunity.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import xjy.smartcommunity.R;
import xjy.smartcommunity.bean.PropertyVo;

/**
 * Created by victorzhang on 2017/8/1.
 */

public class MyListViewAdapter extends BaseAdapter {
        private List<PropertyVo> propertyList;

        public MyListViewAdapter(List<PropertyVo> propertyList) {
            this.propertyList = propertyList;
        }

        @Override
        public int getCount() {
            return propertyList.size();
        }

        @Override
        public Object getItem(int position) {
            return position;
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(final int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
                convertView = LayoutInflater.from(parent.getContext())
                        .inflate(R.layout.listitem_renyuan, parent, false);
                new ViewHolder(convertView);
            }
            ViewHolder holder = (ViewHolder) convertView.getTag();
//            holder.tvType.setText(propertyList.get(position).getType());
            holder.tvName.setText(propertyList.get(position).getName());
            holder.tvPhone.setText(propertyList.get(position).getPhone());
            return convertView;
        }

        class ViewHolder {
            private TextView tvName;
//            private TextView tvType;
            private TextView tvPhone;


            public ViewHolder(View itemView) {
                tvName = (TextView) itemView.findViewById(R.id.RYname);
//                tvType = (TextView) itemView.findViewById(R.id.baoXiuTypeTv);
                tvPhone = (TextView) itemView.findViewById(R.id.RYphone);

                itemView.setTag(this);
            }
        }
    }

